
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>2.Dart语言(2) · Gary的小窝</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="Gary">
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-prism/prism-solarizedlight.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search-pro/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-splitter/splitter.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-tbfed-pagefooter/footer.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-anchor-navigation-ex/style/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-theme-comscore/test.css">
                
            
        

    

    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="widget1.html" />
    
    
    <link rel="prev" href="dart1.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    写在前面
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../leetcode/">
            
                <a href="../leetcode/">
            
                    
                    Leetcode之旅
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="../leetcode/1.html">
            
                <a href="../leetcode/1.html">
            
                    
                    1.两数之和
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="../leetcode/2.html">
            
                <a href="../leetcode/2.html">
            
                    
                    2.两数相加
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.3" data-path="../leetcode/3.html">
            
                <a href="../leetcode/3.html">
            
                    
                    3.无重复字符的最长子串
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.4" data-path="../leetcode/4.html">
            
                <a href="../leetcode/4.html">
            
                    
                    4.寻找两个有序数组的中位数
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.5" data-path="../leetcode/6.html">
            
                <a href="../leetcode/6.html">
            
                    
                    6.Z字形变换
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.6" data-path="../leetcode/9.html">
            
                <a href="../leetcode/9.html">
            
                    
                    9.回文数
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.7" data-path="../leetcode/11.html">
            
                <a href="../leetcode/11.html">
            
                    
                    11.盛最多水的容器
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.8" data-path="../leetcode/12.html">
            
                <a href="../leetcode/12.html">
            
                    
                    12.整数转罗马数字
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.9" data-path="../leetcode/13.html">
            
                <a href="../leetcode/13.html">
            
                    
                    13.罗马数字转整数
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.10" data-path="../leetcode/14.html">
            
                <a href="../leetcode/14.html">
            
                    
                    14.最长公共前缀
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.11" data-path="../leetcode/322.html">
            
                <a href="../leetcode/322.html">
            
                    
                    322.零钱兑换
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.12" data-path="../leetcode/72.html">
            
                <a href="../leetcode/72.html">
            
                    
                    72.编辑距离
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="./">
            
                <a href="./">
            
                    
                    Flutter从入门到放弃
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="dart1.html">
            
                <a href="dart1.html">
            
                    
                    1.Dart语言(1)
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.3.2" data-path="dart2.html">
            
                <a href="dart2.html">
            
                    
                    2.Dart语言(2)
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="widget1.html">
            
                <a href="widget1.html">
            
                    
                    3.Flutter初始化
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.4" data-path="containerText.html">
            
                <a href="containerText.html">
            
                    
                    4.Container和Text组件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.5" data-path="image.html">
            
                <a href="image.html">
            
                    
                    5.Image组件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.6" data-path="chapter2.html">
            
                <a href="chapter2.html">
            
                    
                    6.Flutter 技术总结
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../vue/">
            
                <a href="../vue/">
            
                    
                    Vue组件精讲
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="../vue/1.html">
            
                <a href="../vue/1.html">
            
                    
                    1.provide/inject
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="../vue/2.html">
            
                <a href="../vue/2.html">
            
                    
                    2.手动实现broadcast和dispatch方法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="../js/form.html">
            
                <a href="../js/form.html">
            
                    
                    3.自己动手实现带校验的Form表单组件
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="../js/">
            
                <a href="../js/">
            
                    
                    JavaScript进阶
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="../js/proxy.html">
            
                <a href="../js/proxy.html">
            
                    
                    1.Vue.js 3.0中的响应式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="../js/el.html">
            
                <a href="../js/el.html">
            
                    
                    2.Element UI 源码初探
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.3" data-path="../js/bind.html">
            
                <a href="../js/bind.html">
            
                    
                    3.bind的模拟实现
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.4" data-path="../js/proto.html">
            
                <a href="../js/proto.html">
            
                    
                    4.JS原型和原型链
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.5" data-path="../js/call.html">
            
                <a href="../js/call.html">
            
                    
                    5.模拟实现call和apply
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.6" data-path="../js/ui.html">
            
                <a href="../js/ui.html">
            
                    
                    6.使用Vue cli3搭建组件库并发布到 npm
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.7" data-path="../js/microFE.html">
            
                <a href="../js/microFE.html">
            
                    
                    7.记一次基于qiankun的微前端的改造
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.8" data-path="../js/git.html">
            
                <a href="../js/git.html">
            
                    
                    8.Git的使用
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="../vueLibrary/">
            
                <a href="../vueLibrary/">
            
                    
                    基于Vue的PC端的组件库
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="../vueLibrary/1.html">
            
                <a href="../vueLibrary/1.html">
            
                    
                    1.环境搭建
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="../life/">
            
                <a href="../life/">
            
                    
                    网事杂谈
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.1" data-path="../life/1.html">
            
                <a href="../life/1.html">
            
                    
                    1.周杰伦专辑赏析--叶惠美
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.2" data-path="../life/2.html">
            
                <a href="../life/2.html">
            
                    
                    2.周杰伦专辑赏析--七里香
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >2.Dart语言(2)</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <div id="anchor-navigation-ex-navbar"><i class="fa fa-navicon"></i><ul><ul><li><span class="title-icon "></span><a href="#dart-&#x9762;&#x5411;&#x5BF9;&#x8C61;"><b></b>Dart &#x9762;&#x5411;&#x5BF9;&#x8C61;</a></li><ul><li><span class="title-icon "></span><a href="#&#x7C7B;&#x7684;&#x7B80;&#x5355;&#x4ECB;&#x7ECD;"><b></b>&#x7C7B;&#x7684;&#x7B80;&#x5355;&#x4ECB;&#x7ECD;</a></li><li><span class="title-icon "></span><a href="#&#x6784;&#x9020;&#x51FD;&#x6570;"><b></b>&#x6784;&#x9020;&#x51FD;&#x6570;</a></li><li><span class="title-icon "></span><a href="#&#x7EE7;&#x627F;"><b></b>&#x7EE7;&#x627F;</a></li><li><span class="title-icon "></span><a href="#&#x91CD;&#x8F7D;&#x548C;&#x91CD;&#x5199;"><b></b>&#x91CD;&#x8F7D;&#x548C;&#x91CD;&#x5199;</a></li><li><span class="title-icon "></span><a href="#&#x62BD;&#x8C61;&#x7C7B;"><b></b>&#x62BD;&#x8C61;&#x7C7B;</a></li><li><span class="title-icon "></span><a href="#&#x8BBF;&#x95EE;&#x6743;&#x9650;"><b></b>&#x8BBF;&#x95EE;&#x6743;&#x9650;</a></li><li><span class="title-icon "></span><a href="#&#x9759;&#x6001;&#x65B9;&#x6CD5;"><b></b>&#x9759;&#x6001;&#x65B9;&#x6CD5;</a></li><li><span class="title-icon "></span><a href="#&#x6CDB;&#x578B;"><b></b>&#x6CDB;&#x578B;</a></li><li><span class="title-icon "></span><a href="#asyncawait&#x4ECB;&#x7ECD;"><b></b>async/await&#x4ECB;&#x7ECD;</a></li><li><span class="title-icon "></span><a href="#&#x770B;&#x4E00;&#x4E2A;&#x6848;&#x4F8B;"><b></b>&#x770B;&#x4E00;&#x4E2A;&#x6848;&#x4F8B;</a></li></ul><li><span class="title-icon "></span><a href="#dart&#x5F02;&#x5E38;&#x6355;&#x83B7;"><b></b>Dart&#x5F02;&#x5E38;&#x6355;&#x83B7;</a></li><ul><li><span class="title-icon "></span><a href="#&#x5F02;&#x5E38;&#x5904;&#x7406;&#x5F62;&#x5F0F;"><b></b>&#x5F02;&#x5E38;&#x5904;&#x7406;&#x5F62;&#x5F0F;</a></li><li><span class="title-icon "></span><a href="#&#x6355;&#x83B7;&#x5F02;&#x5E38;"><b></b>&#x6355;&#x83B7;&#x5F02;&#x5E38;</a></li><li><span class="title-icon "></span><a href="#finally&#x8BB2;&#x89E3;"><b></b>Finally&#x8BB2;&#x89E3;</a></li></ul><li><span class="title-icon "></span><a href="#dart&#x679A;&#x4E3E;"><b></b>Dart&#x679A;&#x4E3E;</a></li><ul><li><span class="title-icon "></span><a href="#&#x679A;&#x4E3E;&#x4F7F;&#x7528;"><b></b>&#x679A;&#x4E3E;&#x4F7F;&#x7528;</a></li><li><span class="title-icon "></span><a href="#&#x5143;&#x6570;&#x636E;"><b></b>&#x5143;&#x6570;&#x636E;</a></li><li><span class="title-icon "></span><a href="#&#x81EA;&#x5B9A;&#x4E49;&#x6CE8;&#x89E3;"><b></b>&#x81EA;&#x5B9A;&#x4E49;&#x6CE8;&#x89E3;</a></li></ul><li><span class="title-icon "></span><a href="#dart-&#x5B57;&#x7B26;&#x4E32;"><b></b>Dart &#x5B57;&#x7B26;&#x4E32;</a></li><ul><li><span class="title-icon "></span><a href="#string&#x7B80;&#x5355;&#x4ECB;&#x7ECD;"><b></b>String&#x7B80;&#x5355;&#x4ECB;&#x7ECD;</a></li><li><span class="title-icon "></span><a href="#&#x5355;&#x53CC;&#x5F15;&#x53F7;&#x4E92;&#x76F8;&#x5D4C;&#x5957;"><b></b>&#x5355;&#x53CC;&#x5F15;&#x53F7;&#x4E92;&#x76F8;&#x5D4C;&#x5957;</a></li></ul></ul></ul></div><a href="#" id="anchorNavigationExGoTop"><i class="fa fa-arrow-up"></i></a><h2 id="dart-&#x9762;&#x5411;&#x5BF9;&#x8C61;"><a name="dart-&#x9762;&#x5411;&#x5BF9;&#x8C61;" class="anchor-navigation-ex-anchor" href="#dart-&#x9762;&#x5411;&#x5BF9;&#x8C61;"><i class="fa fa-link" aria-hidden="true"></i></a>Dart &#x9762;&#x5411;&#x5BF9;&#x8C61;</h2>
<h3 id="&#x7C7B;&#x7684;&#x7B80;&#x5355;&#x4ECB;&#x7ECD;"><a name="&#x7C7B;&#x7684;&#x7B80;&#x5355;&#x4ECB;&#x7ECD;" class="anchor-navigation-ex-anchor" href="#&#x7C7B;&#x7684;&#x7B80;&#x5355;&#x4ECB;&#x7ECD;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x7C7B;&#x7684;&#x7B80;&#x5355;&#x4ECB;&#x7ECD;</h3>
<p>&#x521B;&#x5EFA;&#x4E00;&#x4E2A;&#x7C7B;&#x548C;&#x521B;&#x5EFA;&#x7C7B;&#x7684;&#x5B9E;&#x4F8B;</p>
<pre class="language-"><code class="lang-dart"><span class="token keyword">void</span> <span class="token function">test1</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
  Dog d <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Dog</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<span class="token keyword">class</span> <span class="token class-name">Dog</span> <span class="token punctuation">{</span>

<span class="token punctuation">}</span>


<span class="token keyword">var</span> cat <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Cat</span><span class="token punctuation">(</span><span class="token string">&quot;&#x9017;&#x6BD4;&quot;</span><span class="token punctuation">,</span> <span class="token number">12</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">class</span> <span class="token class-name">Cat</span> <span class="token punctuation">{</span>
  String name<span class="token punctuation">;</span>
  int age<span class="token punctuation">;</span>

  <span class="token function">Cat</span><span class="token punctuation">(</span>String name<span class="token punctuation">,</span> int age<span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token keyword">this</span><span class="token punctuation">.</span>name <span class="token operator">=</span> name<span class="token punctuation">;</span>
    <span class="token keyword">this</span><span class="token punctuation">.</span>age <span class="token operator">=</span> age<span class="token punctuation">;</span>
  <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre>
<h3 id="&#x6784;&#x9020;&#x51FD;&#x6570;"><a name="&#x6784;&#x9020;&#x51FD;&#x6570;" class="anchor-navigation-ex-anchor" href="#&#x6784;&#x9020;&#x51FD;&#x6570;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x6784;&#x9020;&#x51FD;&#x6570;</h3>
<p>&#x666E;&#x901A;&#x6784;&#x9020;&#x51FD;&#x6570;</p>
<pre class="language-"><code class="lang-dart"><span class="token keyword">var</span> cat <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Cat</span><span class="token punctuation">(</span><span class="token string">&quot;&#x9017;&#x6BD4;&quot;</span><span class="token punctuation">,</span> <span class="token number">12</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token keyword">class</span> <span class="token class-name">Cat</span> <span class="token punctuation">{</span>
  String name<span class="token punctuation">;</span>
  int age<span class="token punctuation">;</span>

  <span class="token function">Cat</span><span class="token punctuation">(</span>String name<span class="token punctuation">,</span> int age<span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token keyword">this</span><span class="token punctuation">.</span>name <span class="token operator">=</span> name<span class="token punctuation">;</span>
    <span class="token keyword">this</span><span class="token punctuation">.</span>age <span class="token operator">=</span> age<span class="token punctuation">;</span>
  <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre>
<p>&#x547D;&#x540D;&#x6784;&#x9020;&#x51FD;&#x6570;</p>
<p>&#x7ED9;&#x6784;&#x9020;&#x51FD;&#x6570;&#x63D0;&#x4F9B;&#x4E86;&#x540D;&#x79F0;&#xFF0C;&#x8FD9;&#x6837;&#x505A;&#x4F7F;&#x5F97;&#x4E0D;&#x540C;&#x7684;&#x6784;&#x9020;&#x51FD;&#x6570;&#x53D8;&#x7684;&#x66F4;&#x52A0;&#x6E05;&#x6670;&#x3002;</p>
<pre class="language-"><code class="lang-dart">Map map <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Map</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
map<span class="token punctuation">[</span><span class="token string">&apos;name&apos;</span><span class="token punctuation">]</span><span class="token operator">=</span> <span class="token string">&quot;&#x54C8;&#x5DF4;&#x72D7;&quot;</span><span class="token punctuation">;</span>
map<span class="token punctuation">[</span><span class="token string">&apos;age&apos;</span><span class="token punctuation">]</span> <span class="token operator">=</span> <span class="token number">5</span><span class="token punctuation">;</span>
Dog d <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Dog<span class="token punctuation">.</span>newBorn</span><span class="token punctuation">(</span>map<span class="token punctuation">)</span><span class="token punctuation">;</span>


<span class="token keyword">class</span> <span class="token class-name">Dog</span> <span class="token punctuation">{</span>
  String name<span class="token punctuation">;</span>
  int age<span class="token punctuation">;</span>

  <span class="token function">Dog</span><span class="token punctuation">(</span><span class="token keyword">this</span><span class="token punctuation">.</span>name<span class="token punctuation">,</span> <span class="token keyword">this</span><span class="token punctuation">.</span>age<span class="token punctuation">)</span><span class="token punctuation">;</span>

  Dog<span class="token punctuation">.</span><span class="token function">newBorn</span><span class="token punctuation">(</span>Map json<span class="token punctuation">)</span> <span class="token punctuation">{</span>
    name <span class="token operator">=</span> json<span class="token punctuation">[</span><span class="token string">&apos;name&apos;</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
    age <span class="token operator">=</span> json<span class="token punctuation">[</span><span class="token string">&apos;age&apos;</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre>
<h3 id="&#x7EE7;&#x627F;"><a name="&#x7EE7;&#x627F;" class="anchor-navigation-ex-anchor" href="#&#x7EE7;&#x627F;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x7EE7;&#x627F;</h3>
<p>&#x53EF;&#x4EE5;&#x4F7F;&#x7528;extends&#x5173;&#x952E;&#x5B57;&#x7EE7;&#x627F;&#x5176;&#x4ED6;&#x7684;&#x7C7B;&#x3002;</p>
<p>Pug &#x7C7B;&#x7EE7;&#x627F;Dog&#x7C7B;&#xFF0C;&#x901A;&#x8FC7;super&#x5173;&#x952E;&#x5B57;&#x8C03;&#x7528;Dog&#x7C7B;&#x7684;&#x6784;&#x9020;&#x51FD;&#x6570;&#x3002;</p>
<pre class="language-"><code class="lang-dart">Pug p <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Pug</span><span class="token punctuation">(</span><span class="token string">&apos;&#x54C8;&#x54C8;&#x54C8;&apos;</span><span class="token punctuation">,</span> <span class="token number">5</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token function">print</span><span class="token punctuation">(</span>p<span class="token punctuation">.</span>name<span class="token punctuation">)</span><span class="token punctuation">;</span>


<span class="token keyword">class</span> <span class="token class-name">Dog</span> <span class="token punctuation">{</span>
  String name<span class="token punctuation">;</span>
  int age<span class="token punctuation">;</span>

  <span class="token function">Dog</span><span class="token punctuation">(</span><span class="token keyword">this</span><span class="token punctuation">.</span>name<span class="token punctuation">,</span> <span class="token keyword">this</span><span class="token punctuation">.</span>age<span class="token punctuation">)</span><span class="token punctuation">;</span>

  Dog<span class="token punctuation">.</span><span class="token function">newBorn</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
    name <span class="token operator">=</span> <span class="token string">&apos;Doggy&apos;</span><span class="token punctuation">;</span>
    age <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span>
<span class="token punctuation">}</span>

<span class="token keyword">class</span> <span class="token class-name">Pug</span> <span class="token keyword">extends</span> <span class="token class-name">Dog</span> <span class="token punctuation">{</span>
  <span class="token function">Pug</span><span class="token punctuation">(</span>String name<span class="token punctuation">,</span> int age<span class="token punctuation">)</span><span class="token punctuation">:</span> <span class="token keyword">super</span><span class="token punctuation">(</span>name<span class="token punctuation">,</span> age<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre>
<p>&#x4E5F;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;this&#x5173;&#x952E;&#x5B57;&#xFF0C;&#x5728;&#x5192;&#x53F7;&#x4E4B;&#x540E;&#x8C03;&#x7528;&#x540C;&#x4E00;&#x4E2A;&#x7C7B;&#x4E2D;&#x7684;&#x5176;&#x4ED6;&#x6784;&#x9020;&#x51FD;&#x6570;&#x3002;</p>
<p>&#x5B9A;&#x4E49;&#x4E86;&#x4E24;&#x4E2A;&#x547D;&#x540D;&#x6784;&#x9020;&#x51FD;&#x6570;&#xFF0C;&#x4ED6;&#x4EEC;&#x53EA;&#x9700;&#x8981;dog&#x7684;&#x540D;&#x5B57;&#xFF0C;&#x7136;&#x540E;&#x8C03;&#x7528;Pug&#x7684;&#x9ED8;&#x8BA4;&#x6784;&#x9020;&#x51FD;&#x6570;</p>
<pre class="language-"><code class="lang-dart">Pug p <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Pug<span class="token punctuation">.</span>small</span><span class="token punctuation">(</span><span class="token string">&apos;&#x54C8;&#x54C8;&#x54C8;&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token function">print</span><span class="token punctuation">(</span>p<span class="token punctuation">.</span>name<span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token keyword">class</span> <span class="token class-name">Dog</span> <span class="token punctuation">{</span>
  String name<span class="token punctuation">;</span>
  int age<span class="token punctuation">;</span>

  <span class="token function">Dog</span><span class="token punctuation">(</span><span class="token keyword">this</span><span class="token punctuation">.</span>name<span class="token punctuation">,</span> <span class="token keyword">this</span><span class="token punctuation">.</span>age<span class="token punctuation">)</span><span class="token punctuation">;</span>

  Dog<span class="token punctuation">.</span><span class="token function">newBorn</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
    name <span class="token operator">=</span> <span class="token string">&apos;&#x9017;&#x6BD4;&apos;</span><span class="token punctuation">;</span>
    age <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span>
<span class="token punctuation">}</span>

<span class="token keyword">class</span> <span class="token class-name">Pug</span> <span class="token keyword">extends</span> <span class="token class-name">Dog</span> <span class="token punctuation">{</span>
  <span class="token function">Pug</span><span class="token punctuation">(</span>String name<span class="token punctuation">,</span> int age<span class="token punctuation">)</span><span class="token punctuation">:</span> <span class="token keyword">super</span><span class="token punctuation">(</span>name<span class="token punctuation">,</span> age<span class="token punctuation">)</span><span class="token punctuation">;</span>

  Pug<span class="token punctuation">.</span><span class="token function">small</span><span class="token punctuation">(</span>String name<span class="token punctuation">)</span><span class="token punctuation">:</span> <span class="token keyword">this</span><span class="token punctuation">(</span>name<span class="token punctuation">,</span> <span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

  Pug<span class="token punctuation">.</span><span class="token function">large</span><span class="token punctuation">(</span>String name<span class="token punctuation">)</span><span class="token punctuation">:</span> <span class="token keyword">this</span><span class="token punctuation">(</span>name<span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre>
<h3 id="&#x91CD;&#x8F7D;&#x548C;&#x91CD;&#x5199;"><a name="&#x91CD;&#x8F7D;&#x548C;&#x91CD;&#x5199;" class="anchor-navigation-ex-anchor" href="#&#x91CD;&#x8F7D;&#x548C;&#x91CD;&#x5199;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x91CD;&#x8F7D;&#x548C;&#x91CD;&#x5199;</h3>
<p>&#x65B9;&#x6CD5;&#x91CD;&#x5199;</p>
<p>&#x4EE3;&#x7801;&#x5982;&#x4E0B;&#xFF0C;&#x6700;&#x540E;&#x6253;&#x5370;&#x503C;&#x662F;&#xFF1A;&#x4F60;&#x771F;&#x662F;&#x4E2A;&#x9017;&#x6BD4;</p>
<pre class="language-"><code class="lang-dart">Pug p <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Pug</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token function">print</span><span class="token punctuation">(</span>p<span class="token punctuation">.</span><span class="token function">bark</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token keyword">class</span> <span class="token class-name">Dog</span> <span class="token punctuation">{</span>
  <span class="token function">bark</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token function">print</span><span class="token punctuation">(</span><span class="token string">&apos;Bow Wow&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span>
<span class="token punctuation">}</span>

<span class="token keyword">class</span> <span class="token class-name">Pug</span> <span class="token keyword">extends</span> <span class="token class-name">Dog</span> <span class="token punctuation">{</span>
  <span class="token metadata symbol">@override</span>
  <span class="token function">bark</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token function">print</span><span class="token punctuation">(</span><span class="token string">&apos;&#x4F60;&#x771F;&#x662F;&#x4E2A;&#x9017;&#x6BD4;!&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre>
<h3 id="&#x62BD;&#x8C61;&#x7C7B;"><a name="&#x62BD;&#x8C61;&#x7C7B;" class="anchor-navigation-ex-anchor" href="#&#x62BD;&#x8C61;&#x7C7B;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x62BD;&#x8C61;&#x7C7B;</h3>
<ul>
<li><p>&#x53EF;&#x4EE5;&#x901A;&#x8FC7;abstract&#x5173;&#x952E;&#x5B57;&#x58F0;&#x660E;&#x62BD;&#x8C61;&#x7C7B;</p>
</li>
<li><p>&#x53EA;&#x9700;&#x8981;&#x5728;&#x7C7B;&#x58F0;&#x660E;&#x524D;&#x6DFB;&#x52A0;abstract&#x5173;&#x952E;&#x5B57;&#xFF0C;&#x65B9;&#x6CD5;&#x4E0D;&#x9700;&#x8981;&#x3002;&#x65B9;&#x6CD5;&#x53EA;&#x9700;&#x8981;&#x7B7E;&#x540D;&#xFF0C;&#x4E0D;&#x9700;&#x8981;&#x5B9E;&#x73B0;&#x3002;</p>
</li>
</ul>
<pre class="language-"><code class="lang-dart"><span class="token keyword">abstract</span> <span class="token keyword">class</span> <span class="token class-name">AbstractDog</span> <span class="token punctuation">{</span>
  <span class="token keyword">void</span> <span class="token function">eat</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token keyword">void</span> <span class="token function">_hiddenMethod</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">class</span> <span class="token class-name">SmallDog</span> <span class="token keyword">extends</span> <span class="token class-name">AbstractDog</span><span class="token punctuation">{</span>
  <span class="token metadata symbol">@override</span>
  <span class="token keyword">void</span> <span class="token function">_hiddenMethod</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>

  <span class="token punctuation">}</span>

  <span class="token metadata symbol">@override</span>
  <span class="token keyword">void</span> <span class="token function">eat</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>

  <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre>
<h3 id="&#x8BBF;&#x95EE;&#x6743;&#x9650;"><a name="&#x8BBF;&#x95EE;&#x6743;&#x9650;" class="anchor-navigation-ex-anchor" href="#&#x8BBF;&#x95EE;&#x6743;&#x9650;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x8BBF;&#x95EE;&#x6743;&#x9650;</h3>
<ul>
<li>&#x9ED8;&#x8BA4;&#x7C7B;&#x4E2D;&#x7684;&#x6240;&#x6709;&#x5C5E;&#x6027;&#x548C;&#x65B9;&#x6CD5;&#x662F;public&#x7684;&#x3002;&#x5728;dart&#x4E2D;&#xFF0C;&#x53EF;&#x4EE5;&#x5728;&#x5C5E;&#x6027;&#x548C;&#x65B9;&#x6CD5;&#x540D;&#x524D;&#x6DFB;&#x52A0;&#x201C;_&#x201D;&#x4F7F;&#x79C1;&#x6709;&#x5316;&#x3002;&#x73B0;&#x5728;&#x8BA9;&#x6211;&#x4EEC;&#x4F7F;name&#x5C5E;&#x6027;&#x79C1;&#x6709;&#x5316;&#x3002;</li>
<li>&#x53EF;&#x4EE5;&#x53D1;&#x73B0;&#xFF0C;&#x8C03;&#x7528;&#x79C1;&#x6709;&#x5316;&#x53D8;&#x91CF;&#x6216;&#x8005;&#x65B9;&#x6CD5;&#x7684;&#x65F6;&#x5019;&#x4F1A;&#x51FA;&#x73B0;&#x7EA2;&#x8272;&#x8B66;&#x544A;</li>
</ul>
<pre class="language-"><code class="lang-dart">  <span class="token keyword">void</span> <span class="token function">test</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
    Dog d <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Dog</span><span class="token punctuation">(</span><span class="token string">&apos;&#x54C8;&#x5DF4;&#x72D7;&apos;</span><span class="token punctuation">,</span> <span class="token number">5</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">//&#x8FD9;&#x4E2A;&#x62A5;&#x9519;</span>
    <span class="token function">print</span><span class="token punctuation">(</span>d<span class="token punctuation">.</span>name<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token function">print</span><span class="token punctuation">(</span>d<span class="token punctuation">.</span>age<span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span>
</code></pre>
<p>Dog&#x4EE3;&#x7801;&#x5982;&#x4E0B;&#x6240;&#x793A;</p>
<pre class="language-"><code class="lang-dart"><span class="token keyword">class</span> <span class="token class-name">Dog</span> <span class="token punctuation">{</span>
  String _name<span class="token punctuation">;</span>
  int age<span class="token punctuation">;</span>

  <span class="token function">Dog</span><span class="token punctuation">(</span><span class="token keyword">this</span><span class="token punctuation">.</span>_name<span class="token punctuation">,</span> <span class="token keyword">this</span><span class="token punctuation">.</span>age<span class="token punctuation">)</span><span class="token punctuation">;</span>

  String <span class="token keyword">get</span> respectedName <span class="token punctuation">{</span>
    <span class="token keyword">return</span> <span class="token string">&apos;Mr.$_name&apos;</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span>

  <span class="token keyword">set</span> <span class="token function">respectedName</span><span class="token punctuation">(</span>String newName<span class="token punctuation">)</span> <span class="token punctuation">{</span>
    _name <span class="token operator">=</span> newName<span class="token punctuation">;</span>
  <span class="token punctuation">}</span>

  Dog<span class="token punctuation">.</span><span class="token function">newBorn</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
    _name <span class="token operator">=</span> <span class="token string">&apos;&#x54C8;&#x5DF4;&#x72D7;&apos;</span><span class="token punctuation">;</span>
    age <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span>

  <span class="token function">bark</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token function">print</span><span class="token punctuation">(</span><span class="token string">&apos;Bow Wow&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span>

  <span class="token function">_hiddenMethod</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token function">print</span><span class="token punctuation">(</span><span class="token string">&apos;I can only be called internally!&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre>
<h3 id="&#x9759;&#x6001;&#x65B9;&#x6CD5;"><a name="&#x9759;&#x6001;&#x65B9;&#x6CD5;" class="anchor-navigation-ex-anchor" href="#&#x9759;&#x6001;&#x65B9;&#x6CD5;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x9759;&#x6001;&#x65B9;&#x6CD5;</h3>
<p>&#x5982;&#x679C;&#x60F3;&#x8BA9;&#x65B9;&#x6CD5;&#x6216;&#x8005;&#x5C5E;&#x6027;&#x9759;&#x6001;&#x5316;&#xFF0C;&#x53EA;&#x9700;&#x8981;&#x5728;&#x58F0;&#x660E;&#x524D;&#x6DFB;&#x52A0;static&#x5173;&#x952E;&#x5B57;&#x3002;</p>
<pre class="language-"><code class="lang-dart"><span class="token keyword">void</span> <span class="token function">test</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
  Dog<span class="token punctuation">.</span><span class="token function">bark</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>


<span class="token keyword">class</span> <span class="token class-name">Dog</span> <span class="token punctuation">{</span>
  <span class="token keyword">static</span> <span class="token function">bark</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token function">print</span><span class="token punctuation">(</span><span class="token string">&apos;Bow Wow&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre>
<h3 id="&#x6CDB;&#x578B;"><a name="&#x6CDB;&#x578B;" class="anchor-navigation-ex-anchor" href="#&#x6CDB;&#x578B;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x6CDB;&#x578B;</h3>
<p>dart&#x5168;&#x9762;&#x652F;&#x6301;&#x6CDB;&#x578B;&#x3002;&#x5047;&#x8BBE;&#x4F60;&#x60F3;&#x5728;&#x4F60;&#x5B9A;&#x4E49;&#x7684;&#x7C7B;&#x4E2D;&#xFF0C;&#x60F3;&#x6301;&#x6709;&#x4EFB;&#x610F;&#x7C7B;&#x578B;&#x7684;&#x6570;&#x636E;&#x3002;</p>
<pre class="language-"><code class="lang-dart">DataHolder<span class="token operator">&lt;</span>String<span class="token operator">&gt;</span> dataHolder <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">DataHolder</span><span class="token punctuation">(</span><span class="token string">&apos;Some data&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token function">print</span><span class="token punctuation">(</span>dataHolder<span class="token punctuation">.</span><span class="token function">getData</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
dataHolder<span class="token punctuation">.</span><span class="token function">setData</span><span class="token punctuation">(</span><span class="token string">&apos;New Data&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token function">print</span><span class="token punctuation">(</span>dataHolder<span class="token punctuation">.</span><span class="token function">getData</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment">//&#x4E0B;&#x9762;&#x8FD9;&#x4E2A;&#x4F1A;&#x62A5;&#x9519;&#xFF0C;&#x56E0;&#x4E3A;dataHolder&#x5BF9;&#x8C61;&#x5728;&#x521B;&#x5EFA;&#x7684;&#x65F6;&#x5019;&#x5C31;&#x5DF2;&#x7ECF;&#x9650;&#x5236;&#x4E3A;String&#x7C7B;&#x578B;</span>
dataHolder<span class="token punctuation">.</span><span class="token function">setData</span><span class="token punctuation">(</span><span class="token number">123</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token function">print</span><span class="token punctuation">(</span>dataHolder<span class="token punctuation">.</span><span class="token function">getData</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token keyword">class</span> <span class="token class-name">DataHolder</span><span class="token operator">&lt;</span>T<span class="token operator">&gt;</span> <span class="token punctuation">{</span>
  T data<span class="token punctuation">;</span>

  <span class="token function">DataHolder</span><span class="token punctuation">(</span><span class="token keyword">this</span><span class="token punctuation">.</span>data<span class="token punctuation">)</span><span class="token punctuation">;</span>

  <span class="token function">getData</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token keyword">return</span> data<span class="token punctuation">;</span>
  <span class="token punctuation">}</span>

  <span class="token function">setData</span><span class="token punctuation">(</span>data<span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token keyword">this</span><span class="token punctuation">.</span>data <span class="token operator">=</span> data<span class="token punctuation">;</span>
  <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre>
<h3 id="asyncawait&#x4ECB;&#x7ECD;"><a name="asyncawait&#x4ECB;&#x7ECD;" class="anchor-navigation-ex-anchor" href="#asyncawait&#x4ECB;&#x7ECD;"><i class="fa fa-link" aria-hidden="true"></i></a>async/await&#x4ECB;&#x7ECD;</h3>
<p>&#x601D;&#x8003;&#x4E00;&#x4E0B;&#xFF0C;&#x770B;&#x4E86;&#x4E0A;&#x9762;&#x7684;&#x6848;&#x4F8B;&#xFF0C;&#x5BF9;&#x4E8E;future&#x7684;&#x9884;&#x671F;&#x884C;&#x4E3A;&#xFF0C;&#x5982;&#x679C;&#x6211;&#x4EEC;&#x5E0C;&#x671B;&#x5728;&#x6267;&#x884C;&#x5176;&#x4ED6;&#x8BED;&#x53E5;&#x4E4B;&#x524D;&#xFF0C;&#x5148;&#x6267;&#x884C;future&#xFF0C;&#x8BE5;&#x600E;&#x4E48;&#x64CD;&#x4F5C;&#x5462;&#xFF1F;</p>
<p>&#x8FD9;&#x5C31;&#x9700;&#x8981;&#x7528;&#x5230;&#x9700;&#x8981;&#x7528;&#x5230;async/await&#x3002;&#x5728;test&#x51FD;&#x6570;&#x7684;&#x82B1;&#x62EC;&#x53F7;&#x5F00;&#x59CB;&#x6DFB;&#x52A0;async&#x5173;&#x952E;&#x5B57;&#x3002;&#x6211;&#x4EEC;&#x6DFB;&#x52A0;await&#x5173;&#x952E;&#x5B57;&#x5728;&#x8C03;&#x7528;getTest&#x65B9;&#x6CD5;&#x4E4B;&#x524D;&#xFF0C;&#x4ED6;&#x6240;&#x505A;&#x7684;&#x5C31;&#x662F;&#x5728;future&#x8FD4;&#x56DE;&#x503C;&#x4E4B;&#x540E;&#xFF0C;&#x7EE7;&#x7EED;&#x5F80;&#x4E0B;&#x6267;&#x884C;&#x3002;&#x6211;&#x4EEC;&#x5C06;&#x6574;&#x4E2A;&#x4EE3;&#x7801;&#x5305;&#x88F9;&#x5728;try-catch&#x4E2D;&#xFF0C;&#x6211;&#x4EEC;&#x60F3;&#x6355;&#x83B7;&#x6240;&#x6709;&#x7684;&#x5F02;&#x5E38;&#xFF0C;&#x548C;&#x4E4B;&#x524D;&#x4F7F;&#x7528;catchError&#x56DE;&#x8C03;&#x662F;&#x4E00;&#x6837;&#x3002;&#x4F7F;&#x7528;awiat&#x5173;&#x952E;&#x5B57;&#xFF0C;&#x5FC5;&#x987B;&#x7ED9;&#x51FD;&#x6570;&#x6DFB;&#x52A0;async&#x5173;&#x952E;&#x5B57;&#xFF0C;&#x5426;&#x5219;&#x6CA1;&#x6709;&#x6548;&#x679C;&#x3002;</p>
<p>&#x6CE8;&#x610F;&#xFF1A;&#x8981;&#x4F7F;&#x7528; await&#xFF0C;&#x5176;&#x65B9;&#x6CD5;&#x5FC5;&#x987B;&#x5E26;&#x6709; async &#x5173;&#x952E;&#x5B57;&#x3002;&#x53EF;&#x4EE5;&#x4F7F;&#x7528; try, catch, &#x548C; finally &#x6765;&#x5904;&#x7406;&#x4F7F;&#x7528; await &#x7684;&#x5F02;&#x5E38;&#xFF01;</p>
<pre class="language-"><code class="lang-dart">  Future <span class="token function">test</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token keyword">async</span> <span class="token punctuation">{</span>
    <span class="token keyword">try</span> <span class="token punctuation">{</span>
      String value <span class="token operator">=</span> <span class="token keyword">await</span> <span class="token function">getTest</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
      <span class="token function">print</span><span class="token punctuation">(</span><span class="token string">&quot;&#x6D4B;&#x8BD5;----------&quot;</span><span class="token operator">+</span>value<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span> <span class="token keyword">catch</span><span class="token punctuation">(</span>e<span class="token punctuation">)</span> <span class="token punctuation">{</span>
      <span class="token function">print</span><span class="token punctuation">(</span><span class="token string">&apos;&#x6D4B;&#x8BD5;----------Error&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    <span class="token function">print</span><span class="token punctuation">(</span><span class="token string">&apos;&#x6D4B;&#x8BD5;----------&#x9017;&#x6BD4;&#x662F;&#x8FD9;&#x4E2A;&#x5148;&#x6267;&#x884C;&#x5417;&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span>

  Future<span class="token operator">&lt;</span>String<span class="token operator">&gt;</span> <span class="token function">getTest</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token keyword">return</span> <span class="token keyword">new</span> <span class="token class-name">Future</span><span class="token operator">&lt;</span>String<span class="token operator">&gt;</span><span class="token punctuation">.</span><span class="token function">delayed</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">Duration</span><span class="token punctuation">(</span>milliseconds<span class="token punctuation">:</span> <span class="token number">2000</span><span class="token punctuation">)</span><span class="token punctuation">,</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
      <span class="token keyword">return</span> <span class="token string">&quot;This is a doubi&quot;</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span>

  <span class="token number">2019</span><span class="token operator">-</span><span class="token number">06</span><span class="token operator">-</span><span class="token number">21</span> <span class="token number">17</span><span class="token punctuation">:</span><span class="token number">32</span><span class="token punctuation">:</span><span class="token number">37.701</span> <span class="token number">16501</span><span class="token operator">-</span><span class="token number">16583</span><span class="token operator">/</span>com<span class="token punctuation">.</span>hwmc<span class="token punctuation">.</span>auth I<span class="token operator">/</span>flutter<span class="token punctuation">:</span> &#x6D4B;&#x8BD5;<span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span>This <span class="token operator">is</span> a doubi
  <span class="token number">2019</span><span class="token operator">-</span><span class="token number">06</span><span class="token operator">-</span><span class="token number">21</span> <span class="token number">17</span><span class="token punctuation">:</span><span class="token number">32</span><span class="token punctuation">:</span><span class="token number">37.702</span> <span class="token number">16501</span><span class="token operator">-</span><span class="token number">16583</span><span class="token operator">/</span>com<span class="token punctuation">.</span>hwmc<span class="token punctuation">.</span>auth I<span class="token operator">/</span>flutter<span class="token punctuation">:</span> &#x6D4B;&#x8BD5;<span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span>&#x9017;&#x6BD4;&#x662F;&#x8FD9;&#x4E2A;&#x5148;&#x6267;&#x884C;&#x5417;
</code></pre>
<h3 id="&#x770B;&#x4E00;&#x4E2A;&#x6848;&#x4F8B;"><a name="&#x770B;&#x4E00;&#x4E2A;&#x6848;&#x4F8B;" class="anchor-navigation-ex-anchor" href="#&#x770B;&#x4E00;&#x4E2A;&#x6848;&#x4F8B;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x770B;&#x4E00;&#x4E2A;&#x6848;&#x4F8B;</h3>
<p>&#x4E00;&#x4E2A; async &#x65B9;&#x6CD5; &#x662F;&#x51FD;&#x6570;&#x4F53;&#x88AB;&#x6807;&#x8BB0;&#x4E3A; async &#x7684;&#x65B9;&#x6CD5;&#x3002; &#x867D;&#x7136;&#x5F02;&#x6B65;&#x65B9;&#x6CD5;&#x7684;&#x6267;&#x884C;&#x53EF;&#x80FD;&#x9700;&#x8981;&#x4E00;&#x5B9A;&#x65F6;&#x95F4;&#xFF0C;&#x4F46;&#x662F; &#x5F02;&#x6B65;&#x65B9;&#x6CD5;&#x7ACB;&#x523B;&#x8FD4;&#x56DE; - &#x5728;&#x65B9;&#x6CD5;&#x4F53;&#x8FD8;&#x6CA1;&#x6267;&#x884C;&#x4E4B;&#x524D;&#x5C31;&#x8FD4;&#x56DE;&#x4E86;</p>
<pre class="language-"><code class="lang-dart"><span class="token keyword">void</span> getHttp <span class="token keyword">async</span> <span class="token punctuation">{</span>
    <span class="token comment">// TODO ---</span>
<span class="token punctuation">}</span>
</code></pre>
<p>&#x5728;&#x4E00;&#x4E2A;&#x65B9;&#x6CD5;&#x4E0A;&#x6DFB;&#x52A0; async &#x5173;&#x952E;&#x5B57;&#xFF0C;&#x5219;&#x8FD9;&#x4E2A;&#x65B9;&#x6CD5;&#x8FD4;&#x56DE;&#x503C;&#x4E3A; Future&#x3002;</p>
<p>&#x4F8B;&#x5982;&#xFF0C;&#x4E0B;&#x9762;&#x662F;&#x4E00;&#x4E2A;&#x8FD4;&#x56DE;&#x5B57;&#x7B26;&#x4E32;&#x7684;&#x540C;&#x6B65;&#x65B9;&#x6CD5;&#xFF1A;</p>
<pre class="language-"><code class="lang-dart">String <span class="token function">loadAppVersion</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=</span><span class="token operator">&gt;</span> <span class="token string">&quot;1.0.2&quot;</span>
</code></pre>
<p>&#x4F7F;&#x7528; async &#x5173;&#x952E;&#x5B57;&#xFF0C;&#x5219;&#x8BE5;&#x65B9;&#x6CD5;&#x8FD4;&#x56DE;&#x4E00;&#x4E2A; Future&#xFF0C;&#x5E76;&#x4E14; &#x8BA4;&#x4E3A;&#x8BE5;&#x51FD;&#x6570;&#x662F;&#x4E00;&#x4E2A;&#x8017;&#x65F6;&#x7684;&#x64CD;&#x4F5C;&#x3002;</p>
<pre class="language-"><code class="lang-dart">Futre<span class="token operator">&lt;</span>String<span class="token operator">&gt;</span> <span class="token function">loadAppVersion</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token keyword">async</span>  <span class="token operator">=</span><span class="token operator">&gt;</span> <span class="token string">&quot;1.0.2&quot;</span>
</code></pre>
<p>&#x6CE8;&#x610F;&#xFF0C;&#x65B9;&#x6CD5;&#x7684;&#x51FD;&#x6570;&#x4F53;&#x5E76;&#x4E0D;&#x9700;&#x8981;&#x4F7F;&#x7528; Future API&#x3002; Dart &#x4F1A;&#x81EA;&#x52A8;&#x5728;&#x9700;&#x8981;&#x7684;&#x65F6;&#x5019;&#x521B;&#x5EFA; Future &#x5BF9;&#x8C61;&#x3002;</p>
<p>&#x597D;&#x7684;&#x4EE3;&#x7801;&#x662F;&#x8FD9;&#x6837;&#x7684;</p>
<pre class="language-"><code class="lang-dart"><span class="token keyword">void</span> <span class="token function">main</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
 <span class="token comment">//&#x8C03;&#x7528;&#x5F02;&#x6B65;&#x65B9;&#x6CD5;</span>
 <span class="token function">doAsync</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token comment">// &#x5728;&#x51FD;&#x6570;&#x4E0A;&#x58F0;&#x660E;&#x4E86; async &#x8868;&#x660E;&#x8FD9;&#x662F;&#x4E00;&#x4E2A;&#x5F02;&#x6B65;&#x65B9;&#x6CD5;</span>
Future<span class="token operator">&lt;</span>bool<span class="token operator">&gt;</span> <span class="token function">doAsync</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token keyword">async</span> <span class="token punctuation">{</span>
  <span class="token keyword">try</span> <span class="token punctuation">{</span>
    <span class="token comment">// &#x8FD9;&#x91CC;&#x662F;&#x4E00;&#x4E2A;&#x6A21;&#x62DF;&#x8BF7;&#x6C42;&#x4E00;&#x4E2A;&#x7F51;&#x7EDC;&#x8017;&#x65F6;&#x64CD;&#x4F5C;</span>
    <span class="token keyword">var</span> result <span class="token operator">=</span> <span class="token keyword">await</span> <span class="token function">getHttp</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">//&#x8BF7;&#x6C42;&#x51FA;&#x6765;&#x7684;&#x7ED3;&#x679C;</span>
    <span class="token keyword">return</span> <span class="token function">printResult</span><span class="token punctuation">(</span>result<span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span> <span class="token keyword">catch</span> <span class="token punctuation">(</span>e<span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token function">print</span><span class="token punctuation">(</span>e<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">return</span> <span class="token boolean">false</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token comment">//&#x5C06;&#x8BF7;&#x6C42;&#x51FA;&#x6765;&#x7684;&#x7ED3;&#x679C;&#x6253;&#x5370;&#x51FA;&#x6765;</span>
Future<span class="token operator">&lt;</span>bool<span class="token operator">&gt;</span> <span class="token function">printResult</span><span class="token punctuation">(</span>summary<span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token function">print</span><span class="token punctuation">(</span>summary<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token comment">//&#x5F00;&#x59CB;&#x6A21;&#x62DF;&#x7F51;&#x7EDC;&#x8BF7;&#x6C42; &#x7B49;&#x5F85; 5 &#x79D2;&#x8FD4;&#x56DE;&#x4E00;&#x4E2A;&#x5B57;&#x7B26;&#x4E32;</span>
<span class="token function">getHttp</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
 <span class="token keyword">return</span> <span class="token keyword">new</span> <span class="token class-name">Future<span class="token punctuation">.</span>delayed</span><span class="token punctuation">(</span><span class="token function">Duration</span><span class="token punctuation">(</span>seconds<span class="token punctuation">:</span> <span class="token number">5</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=</span><span class="token operator">&gt;</span> <span class="token string">&quot;Request Succeeded&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre>
<p>&#x4E0D;&#x597D;&#x7684;&#x5199;&#x6CD5;</p>
<pre class="language-"><code class="lang-dart"><span class="token keyword">void</span> <span class="token function">main</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
 <span class="token function">doAsync</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

Future<span class="token operator">&lt;</span>String<span class="token operator">&gt;</span> <span class="token function">doAsync</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token keyword">async</span> <span class="token punctuation">{</span>
    <span class="token keyword">return</span>  <span class="token function">getHttp</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">then</span><span class="token punctuation">(</span><span class="token punctuation">(</span>r<span class="token punctuation">)</span><span class="token punctuation">{</span>
      <span class="token keyword">return</span> <span class="token function">printResult</span><span class="token punctuation">(</span>r<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">catchError</span><span class="token punctuation">(</span><span class="token punctuation">(</span>e<span class="token punctuation">)</span><span class="token punctuation">{</span>
      <span class="token function">print</span><span class="token punctuation">(</span>e<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

Future<span class="token operator">&lt;</span>String<span class="token operator">&gt;</span> <span class="token function">printResult</span><span class="token punctuation">(</span>summary<span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token function">print</span><span class="token punctuation">(</span>summary<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

Future<span class="token operator">&lt;</span>String<span class="token operator">&gt;</span> <span class="token function">getHttp</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
 <span class="token keyword">return</span> <span class="token keyword">new</span> <span class="token class-name">Future<span class="token punctuation">.</span>delayed</span><span class="token punctuation">(</span><span class="token function">Duration</span><span class="token punctuation">(</span>seconds<span class="token punctuation">:</span> <span class="token number">5</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=</span><span class="token operator">&gt;</span> <span class="token string">&quot;Request Succeeded&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre>
<h2 id="dart&#x5F02;&#x5E38;&#x6355;&#x83B7;"><a name="dart&#x5F02;&#x5E38;&#x6355;&#x83B7;" class="anchor-navigation-ex-anchor" href="#dart&#x5F02;&#x5E38;&#x6355;&#x83B7;"><i class="fa fa-link" aria-hidden="true"></i></a>Dart&#x5F02;&#x5E38;&#x6355;&#x83B7;</h2>
<h3 id="&#x5F02;&#x5E38;&#x5904;&#x7406;&#x5F62;&#x5F0F;"><a name="&#x5F02;&#x5E38;&#x5904;&#x7406;&#x5F62;&#x5F0F;" class="anchor-navigation-ex-anchor" href="#&#x5F02;&#x5E38;&#x5904;&#x7406;&#x5F62;&#x5F0F;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x5F02;&#x5E38;&#x5904;&#x7406;&#x5F62;&#x5F0F;</h3>
<p>dart &#x4F7F;&#x7528;&#x7ECF;&#x5178;&#x7684;try-catch&#x5904;&#x7406;&#x5F02;&#x5E38;&#xFF0C;&#x4F7F;&#x7528;&#x5173;&#x952E;&#x5B57;throw&#x629B;&#x51FA;&#x4E00;&#x4E2A;&#x5F02;&#x5E38;&#x3002;</p>
<pre class="language-"><code class="lang-dart">  <span class="token keyword">void</span> <span class="token function">test1</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
    <span class="token function">divide</span><span class="token punctuation">(</span><span class="token number">10</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span>

  <span class="token function">divide</span><span class="token punctuation">(</span>int a<span class="token punctuation">,</span> int b<span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token keyword">if</span> <span class="token punctuation">(</span>b <span class="token operator">==</span> <span class="token number">0</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
      <span class="token keyword">throw</span> <span class="token keyword">new</span> <span class="token class-name">IntegerDivisionByZeroException</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    <span class="token keyword">return</span> a <span class="token operator">/</span> b<span class="token punctuation">;</span>
  <span class="token punctuation">}</span>
</code></pre>
<p>&#x5F53;b&#x53D8;&#x91CF;&#x7684;&#x503C;&#x4E3A;0&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x629B;&#x51FA;&#x4E00;&#x4E2A;&#x5185;&#x7F6E;&#x7684;&#x5F02;&#x5E38;IntegerDivisionByZeroException&#x3002;</p>
<p>&#x5982;&#x4F55;&#x5B9A;&#x4E49;&#x5F02;&#x5E38;&#x65E5;&#x5FD7;&#x5462;&#xFF1F;</p>
<p>&#x53EF;&#x4EE5;&#x5728;&#x5F02;&#x5E38;&#x4E2D;&#x643A;&#x5E26;&#x4E00;&#x4E2A;&#x5B57;&#x7B26;&#x4E32;&#x4FE1;&#x606F;&#x3002;</p>
<pre class="language-"><code class="lang-dart">  <span class="token keyword">void</span> <span class="token function">test1</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
    <span class="token function">divide</span><span class="token punctuation">(</span><span class="token number">10</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span>

  <span class="token function">divide</span><span class="token punctuation">(</span>int a<span class="token punctuation">,</span> int b<span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token keyword">if</span> <span class="token punctuation">(</span>b <span class="token operator">==</span> <span class="token number">0</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
      <span class="token keyword">throw</span> <span class="token keyword">new</span> <span class="token class-name">Exception</span><span class="token punctuation">(</span><span class="token string">&apos;&#x9017;&#x6BD4;&#xFF0C;&#x4E0D;&#x80FD;&#x4E3A;0&#x7684;&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    <span class="token keyword">return</span> a <span class="token operator">/</span> b<span class="token punctuation">;</span>
  <span class="token punctuation">}</span>
</code></pre>
<h3 id="&#x6355;&#x83B7;&#x5F02;&#x5E38;"><a name="&#x6355;&#x83B7;&#x5F02;&#x5E38;" class="anchor-navigation-ex-anchor" href="#&#x6355;&#x83B7;&#x5F02;&#x5E38;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x6355;&#x83B7;&#x5F02;&#x5E38;</h3>
<p>&#x67D0;&#x79CD;&#x7C7B;&#x578B;&#x7684;&#x5F02;&#x5E38;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;on&#x5173;&#x952E;&#x5B57;&#x6355;&#x83B7;&#xFF0C;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre class="language-"><code class="lang-dart">  <span class="token keyword">void</span> <span class="token function">test1</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
    <span class="token keyword">try</span> <span class="token punctuation">{</span>
      <span class="token function">divide</span><span class="token punctuation">(</span><span class="token number">10</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span> on IntegerDivisionByZeroException <span class="token punctuation">{</span>
      <span class="token function">print</span><span class="token punctuation">(</span><span class="token string">&apos;&#x9017;&#x6BD4;&#xFF0C;&#x5F02;&#x5E38;&#x88AB;&#x6355;&#x83B7;&#x4E86;&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
  <span class="token punctuation">}</span>

  <span class="token function">divide</span><span class="token punctuation">(</span>int a<span class="token punctuation">,</span> int b<span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token keyword">if</span> <span class="token punctuation">(</span>b <span class="token operator">==</span> <span class="token number">0</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
      <span class="token keyword">throw</span> <span class="token keyword">new</span> <span class="token class-name">IntegerDivisionByZeroException</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    <span class="token keyword">return</span> a <span class="token operator">/</span> b<span class="token punctuation">;</span>
  <span class="token punctuation">}</span>
</code></pre>
<p>&#x6CE8;&#x610F;&#x95EE;&#x9898;&#xFF0C;&#x6355;&#x83B7;&#x7684;&#x5F02;&#x5E38;&#x5C42;&#x7EA7;&#x8981;&#x5927;&#x4E8E;&#x629B;&#x51FA;&#x7684;&#x5F02;&#x5E38;&#xFF0C;&#x5426;&#x5219;&#x6355;&#x83B7;&#x4F1A;&#x5931;&#x8D25;</p>
<p>&#x8FD8;&#x662F;&#x4F1A;&#x629B;&#x51FA;&#x5F02;&#x5E38;&apos;&#x9017;&#x6BD4;&#xFF0C;&#x4E0D;&#x80FD;&#x4E3A;0&#x7684;&apos;&#xFF0C;&#x56E0;&#x4E3A;Exception&#x6BD4;
IntegerDivisionByZeroException&#x5C42;&#x7EA7;&#x8981;&#x9AD8;</p>
<pre class="language-"><code class="lang-dart">  <span class="token keyword">void</span> <span class="token function">test1</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
    <span class="token keyword">try</span> <span class="token punctuation">{</span>
      <span class="token function">divide</span><span class="token punctuation">(</span><span class="token number">10</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span> on IntegerDivisionByZeroException <span class="token punctuation">{</span>
      <span class="token function">print</span><span class="token punctuation">(</span><span class="token string">&apos;&#x9017;&#x6BD4;&#xFF0C;&#x5F02;&#x5E38;&#x88AB;&#x6355;&#x83B7;&#x4E86;&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
  <span class="token punctuation">}</span>

  <span class="token function">divide</span><span class="token punctuation">(</span>int a<span class="token punctuation">,</span> int b<span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token keyword">if</span> <span class="token punctuation">(</span>b <span class="token operator">==</span> <span class="token number">0</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
      <span class="token keyword">throw</span> <span class="token keyword">new</span> <span class="token class-name">Exception</span><span class="token punctuation">(</span><span class="token string">&apos;&#x9017;&#x6BD4;&#xFF0C;&#x4E0D;&#x80FD;&#x4E3A;0&#x7684;&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    <span class="token keyword">return</span> a <span class="token operator">/</span> b<span class="token punctuation">;</span>
  <span class="token punctuation">}</span>
</code></pre>
<p>&#x5982;&#x679C;&#x4F60;&#x4E0D;&#x77E5;&#x9053;&#x629B;&#x51FA;&#x5F02;&#x5E38;&#x7684;&#x7C7B;&#x578B;&#xFF0C;&#x6216;&#x8005;&#x4E0D;&#x786E;&#x5B9A;&#xFF0C;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;catch&#x5757;&#x5904;&#x7406;&#x4EFB;&#x610F;&#x7C7B;&#x578B;&#x7684;&#x5F02;&#x5E38;&#x3002;</p>
<pre class="language-"><code class="lang-dart">  <span class="token keyword">void</span> <span class="token function">test1</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
    <span class="token keyword">try</span> <span class="token punctuation">{</span>
      <span class="token function">divide</span><span class="token punctuation">(</span><span class="token number">10</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span> on IntegerDivisionByZeroException <span class="token punctuation">{</span>
      <span class="token function">print</span><span class="token punctuation">(</span><span class="token string">&apos;&#x9017;&#x6BD4;&#xFF0C;&#x5F02;&#x5E38;&#x88AB;&#x6355;&#x83B7;&#x4E86;&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span> <span class="token keyword">catch</span> <span class="token punctuation">(</span>e<span class="token punctuation">)</span> <span class="token punctuation">{</span>
      <span class="token function">print</span><span class="token punctuation">(</span>e<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
  <span class="token punctuation">}</span>

  <span class="token function">divide</span><span class="token punctuation">(</span>int a<span class="token punctuation">,</span> int b<span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token keyword">if</span> <span class="token punctuation">(</span>b <span class="token operator">==</span> <span class="token number">0</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
      <span class="token keyword">throw</span> <span class="token keyword">new</span> <span class="token class-name">Exception</span><span class="token punctuation">(</span><span class="token string">&apos;yc other exception.&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    <span class="token keyword">return</span> a <span class="token operator">/</span> b<span class="token punctuation">;</span>
  <span class="token punctuation">}</span>
</code></pre>
<h3 id="finally&#x8BB2;&#x89E3;"><a name="finally&#x8BB2;&#x89E3;" class="anchor-navigation-ex-anchor" href="#finally&#x8BB2;&#x89E3;"><i class="fa fa-link" aria-hidden="true"></i></a>Finally&#x8BB2;&#x89E3;</h3>
<p>dart&#x4E5F;&#x63D0;&#x4F9B;&#x4E86;finally&#x5757;&#xFF0C;&#x5373;&#x662F;&#x5426;&#x53D1;&#x751F;&#x5F02;&#x5E38;&#x8FD9;&#x4E2A;&#x5757;&#x90FD;&#x4F1A;&#x6267;&#x884C;&#x3002;</p>
<pre class="language-"><code class="lang-dart">  <span class="token keyword">void</span> <span class="token function">test1</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
    <span class="token keyword">try</span> <span class="token punctuation">{</span>
      <span class="token function">divide</span><span class="token punctuation">(</span><span class="token number">10</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span> on IntegerDivisionByZeroException <span class="token punctuation">{</span>
      <span class="token function">print</span><span class="token punctuation">(</span><span class="token string">&apos;&#x9017;&#x6BD4;&#xFF0C;&#x5F02;&#x5E38;&#x88AB;&#x6355;&#x83B7;&#x4E86;&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span> <span class="token keyword">catch</span> <span class="token punctuation">(</span>e<span class="token punctuation">)</span> <span class="token punctuation">{</span>
      <span class="token function">print</span><span class="token punctuation">(</span>e<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span><span class="token keyword">finally</span> <span class="token punctuation">{</span>
      <span class="token function">print</span><span class="token punctuation">(</span><span class="token string">&apos;I will always be executed!&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
  <span class="token punctuation">}</span>

  <span class="token function">divide</span><span class="token punctuation">(</span>int a<span class="token punctuation">,</span> int b<span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token keyword">if</span> <span class="token punctuation">(</span>b <span class="token operator">==</span> <span class="token number">0</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
      <span class="token keyword">throw</span> <span class="token keyword">new</span> <span class="token class-name">Exception</span><span class="token punctuation">(</span><span class="token string">&apos;yc other exception.&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    <span class="token keyword">return</span> a <span class="token operator">/</span> b<span class="token punctuation">;</span>
  <span class="token punctuation">}</span>
</code></pre>
<h2 id="dart&#x679A;&#x4E3E;"><a name="dart&#x679A;&#x4E3E;" class="anchor-navigation-ex-anchor" href="#dart&#x679A;&#x4E3E;"><i class="fa fa-link" aria-hidden="true"></i></a>Dart&#x679A;&#x4E3E;</h2>
<h3 id="&#x679A;&#x4E3E;&#x4F7F;&#x7528;"><a name="&#x679A;&#x4E3E;&#x4F7F;&#x7528;" class="anchor-navigation-ex-anchor" href="#&#x679A;&#x4E3E;&#x4F7F;&#x7528;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x679A;&#x4E3E;&#x4F7F;&#x7528;</h3>
<p>dart &#x652F;&#x6301;&#x679A;&#x4E3E;&#xFF0C;&#x7528;&#x6CD5;&#x548C;java&#x4E00;&#x6837;&#x3002;</p>
<pre class="language-"><code class="lang-dart">Dog d <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Dog</span><span class="token punctuation">(</span><span class="token string">&apos;&#x54C8;&#x5DF4;&#x72D7;&apos;</span><span class="token punctuation">,</span> <span class="token number">12</span><span class="token punctuation">,</span> CurrentState<span class="token punctuation">.</span>sleeping<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token function">print</span><span class="token punctuation">(</span>d<span class="token punctuation">.</span>state <span class="token operator">==</span> CurrentState<span class="token punctuation">.</span>sleeping<span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">//Prints &apos;true&apos;</span>


<span class="token keyword">enum</span> CurrentState <span class="token punctuation">{</span>
  sleeping<span class="token punctuation">,</span>
  barking<span class="token punctuation">,</span>
  eating<span class="token punctuation">,</span>
  walking
<span class="token punctuation">}</span>

<span class="token keyword">class</span> <span class="token class-name">Dog</span> <span class="token punctuation">{</span>
  String name<span class="token punctuation">;</span>
  int age<span class="token punctuation">;</span>
  CurrentState state<span class="token punctuation">;</span>

  <span class="token function">Dog</span><span class="token punctuation">(</span><span class="token keyword">this</span><span class="token punctuation">.</span>name<span class="token punctuation">,</span> <span class="token keyword">this</span><span class="token punctuation">.</span>age<span class="token punctuation">,</span> <span class="token keyword">this</span><span class="token punctuation">.</span>state<span class="token punctuation">)</span><span class="token punctuation">;</span>

  <span class="token keyword">static</span> <span class="token function">bark</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token function">print</span><span class="token punctuation">(</span><span class="token string">&apos;Bow Wow&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre>
<h3 id="&#x5143;&#x6570;&#x636E;"><a name="&#x5143;&#x6570;&#x636E;" class="anchor-navigation-ex-anchor" href="#&#x5143;&#x6570;&#x636E;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x5143;&#x6570;&#x636E;</h3>
<p>&#x4F7F;&#x7528;&#x5143;&#x6570;&#x636E;&#x7ED9;&#x4EE3;&#x7801;&#x6DFB;&#x52A0;&#x989D;&#x5916;&#x4FE1;&#x606F;&#xFF0C;&#x5143;&#x6570;&#x636E;&#x6CE8;&#x89E3;&#x662F;&#x4EE5;@&#x5B57;&#x7B26;&#x5F00;&#x5934;&#xFF0C;&#x540E;&#x9762;&#x662F;&#x4E00;&#x4E2A;&#x7F16;&#x8BD1;&#x65F6;&#x5E38;&#x91CF;&#x6216;&#x8005;&#x8C03;&#x7528;&#x4E00;&#x4E2A;&#x5E38;&#x91CF;&#x6784;&#x9020;&#x51FD;&#x6570;&#x3002;</p>
<p>&#x6709;&#x4E09;&#x4E2A;&#x6CE8;&#x89E3;&#x6240;&#x6709;&#x7684;Dart&#x4EE3;&#x7801;&#x90FD;&#x53EF;&#x4F7F;&#x7528;&#xFF1A;@deprecated&#x3001;@override&#xFF0C;@proxy,</p>
<p>&#x5143;&#x6570;&#x636E;&#x53EF;&#x4EE5;&#x5728;library&#x3001;typedef&#x3001;type parameter&#x3001;constructor&#x3001;factory&#x3001;function&#x3001;field&#x3001;parameter&#x3001;&#x6216;&#x8005;variable&#x58F0;&#x660E;&#x4E4B;&#x524D;&#x4F7F;&#x7528;&#xFF0C;&#x4E5F;&#x53EF;&#x4EE5;&#x5728;import&#x6216;&#x8005;export&#x6307;&#x4EE4;&#x4E4B;&#x524D;&#x4F7F;&#x7528;&#xFF0C;&#x4F7F;&#x7528;&#x53CD;&#x5C04;&#x53EF;&#x4EE5;&#x518D;&#x8FD0;&#x884C;&#x65F6;&#x83B7;&#x53D6;&#x5143;&#x6570;&#x636E;&#x4FE1;&#x606F;&#x3002;</p>
<h3 id="&#x81EA;&#x5B9A;&#x4E49;&#x6CE8;&#x89E3;"><a name="&#x81EA;&#x5B9A;&#x4E49;&#x6CE8;&#x89E3;" class="anchor-navigation-ex-anchor" href="#&#x81EA;&#x5B9A;&#x4E49;&#x6CE8;&#x89E3;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x81EA;&#x5B9A;&#x4E49;&#x6CE8;&#x89E3;</h3>
<p>&#x5B9A;&#x4E49;&#x81EA;&#x5DF1;&#x7684;&#x5143;&#x6570;&#x636E;&#x6CE8;&#x89E3;&#x3002;&#x4E0B;&#x9762;&#x7684;&#x793A;&#x4F8B;&#x5B9A;&#x4E49;&#x4E00;&#x4E2A;&#x5E26;&#x6709;&#x4E24;&#x4E2A;&#x53C2;&#x6570;&#x7684;@toDo&#x6CE8;&#x89E3;&#xFF1A;</p>
<pre class="language-"><code class="lang-dart"><span class="token keyword">void</span> <span class="token function">test1</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token function">doSomething</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>


<span class="token metadata symbol">@toDo</span><span class="token punctuation">(</span><span class="token string">&apos;seth&apos;</span><span class="token punctuation">,</span> <span class="token string">&apos;make this do something&apos;</span><span class="token punctuation">)</span>
<span class="token keyword">void</span> <span class="token function">doSomething</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token function">print</span><span class="token punctuation">(</span><span class="token string">&apos;do something&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">class</span> <span class="token class-name">toDo</span> <span class="token punctuation">{</span>
  <span class="token keyword">final</span> String who<span class="token punctuation">;</span>
  <span class="token keyword">final</span> String what<span class="token punctuation">;</span>
  <span class="token keyword">const</span> <span class="token function">toDo</span><span class="token punctuation">(</span><span class="token keyword">this</span><span class="token punctuation">.</span>who<span class="token punctuation">,</span> <span class="token keyword">this</span><span class="token punctuation">.</span>what<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre>
<h2 id="dart-&#x5B57;&#x7B26;&#x4E32;"><a name="dart-&#x5B57;&#x7B26;&#x4E32;" class="anchor-navigation-ex-anchor" href="#dart-&#x5B57;&#x7B26;&#x4E32;"><i class="fa fa-link" aria-hidden="true"></i></a>Dart &#x5B57;&#x7B26;&#x4E32;</h2>
<h3 id="string&#x7B80;&#x5355;&#x4ECB;&#x7ECD;"><a name="string&#x7B80;&#x5355;&#x4ECB;&#x7ECD;" class="anchor-navigation-ex-anchor" href="#string&#x7B80;&#x5355;&#x4ECB;&#x7ECD;"><i class="fa fa-link" aria-hidden="true"></i></a>String&#x7B80;&#x5355;&#x4ECB;&#x7ECD;</h3>
<p>Dart&#x5B57;&#x7B26;&#x4E32;&#x662F;UTF-16&#x7F16;&#x7801;&#x7684;&#x5B57;&#x7B26;&#x5E8F;&#x5217;&#xFF0C;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x5355;&#x5F15;&#x53F7;&#x6216;&#x8005;&#x53CC;&#x5F15;&#x53F7;&#x6765;&#x521B;&#x5EFA;&#x5B57;&#x7B26;&#x4E32;&#xFF1A;</p>
<pre class="language-"><code class="lang-dart">String str1 <span class="token operator">=</span> <span class="token string">&apos;&#x5355;&#x5F15;&#x53F7;&#x5B57;&#x7B26;&#x4E32;&apos;</span><span class="token punctuation">;</span>
String str2 <span class="token operator">=</span> <span class="token string">&quot;&#x53CC;&#x5F15;&#x53F7;&#x5B57;&#x7B26;&#x4E32;&quot;</span><span class="token punctuation">;</span>

<span class="token function">print</span><span class="token punctuation">(</span>str1<span class="token punctuation">)</span><span class="token punctuation">;</span>        <span class="token comment">//&#x8F93;&#x51FA;&#xFF1A;&#x5355;&#x5F15;&#x53F7;&#x5B57;&#x7B26;&#x4E32;</span>
<span class="token function">print</span><span class="token punctuation">(</span>str2<span class="token punctuation">)</span><span class="token punctuation">;</span>        <span class="token comment">//&#x8F93;&#x51FA;&#xFF1A;&#x53CC;&#x5F15;&#x53F7;&#x5B57;&#x7B26;&#x4E32;</span>
</code></pre>
<h3 id="&#x5355;&#x53CC;&#x5F15;&#x53F7;&#x4E92;&#x76F8;&#x5D4C;&#x5957;"><a name="&#x5355;&#x53CC;&#x5F15;&#x53F7;&#x4E92;&#x76F8;&#x5D4C;&#x5957;" class="anchor-navigation-ex-anchor" href="#&#x5355;&#x53CC;&#x5F15;&#x53F7;&#x4E92;&#x76F8;&#x5D4C;&#x5957;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x5355;&#x53CC;&#x5F15;&#x53F7;&#x4E92;&#x76F8;&#x5D4C;&#x5957;</h3>
<p>String&#x4E2D;&#x5355;&#x3001;&#x53CC;&#x5F15;&#x53F7;&#x4E92;&#x76F8;&#x5D4C;&#x5957;&#x60C5;&#x51B5;&#x5982;&#x4E0B;&#x6240;&#x793A;</p>
<pre class="language-"><code class="lang-dart">String str1 <span class="token operator">=</span> <span class="token string">&apos;&#x5355;&#x5F15;&#x53F7;&#x4E2D;&#x7684;&quot;&#x53CC;&#x5F15;&#x53F7;&quot;&#x5B57;&#x7B26;&#x4E32;&apos;</span><span class="token punctuation">;</span>
String str2 <span class="token operator">=</span> <span class="token string">&quot;&#x53CC;&#x5F15;&#x53F7;&#x4E2D;&#x7684;&apos;&#x5355;&#x5F15;&#x53F7;&apos;&#x5B57;&#x7B26;&#x4E32;&quot;</span><span class="token punctuation">;</span>

<span class="token function">print</span><span class="token punctuation">(</span><span class="token string">&quot;yc-str1--&quot;</span> <span class="token operator">+</span> str1<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token function">print</span><span class="token punctuation">(</span><span class="token string">&quot;yc-str2--&quot;</span> <span class="token operator">+</span> str2<span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token comment">//&#x5355;&#x5F15;&#x53F7;&#x91CC;&#x9762;&#x6709;&#x5355;&#x5F15;&#x53F7;&#xFF0C;&#x5FC5;&#x987B;&#x5728;&#x524D;&#x9762;&#x52A0;&#x53CD;&#x659C;&#x6760;</span>
String str3 <span class="token operator">=</span> <span class="token string">&apos;&#x5355;&#x5F15;&#x53F7;&#x4E2D;&#x7684;\&apos;&#x5355;&#x5F15;&#x53F7;\&apos;&apos;</span><span class="token punctuation">;</span>
String str4 <span class="token operator">=</span> <span class="token string">&quot;&#x53CC;&#x5F15;&#x53F7;&#x91CC;&#x9762;&#x6709;&#x53CC;&#x5F15;&#x53F7;,\&quot;&#x53CC;&#x5F15;&#x53F7;\&quot;&quot;</span><span class="token punctuation">;</span>
<span class="token function">print</span><span class="token punctuation">(</span><span class="token string">&quot;yc-str3--&quot;</span> <span class="token operator">+</span> str3<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token function">print</span><span class="token punctuation">(</span><span class="token string">&quot;yc-str4--&quot;</span> <span class="token operator">+</span> str4<span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre>
<p>&#x6CE8;&#x610F;&#x70B9;:&#xFF1A;</p>
<p>&#x5355;&#x5F15;&#x53F7;&#x5D4C;&#x5957;&#x5355;&#x5F15;&#x53F7;&#x4E4B;&#x95F4;&#x4E0D;&#x5141;&#x8BB8;&#x51FA;&#x73B0;&#x7A7A;&#x4E32;&#xFF08;&#x4E0D;&#x662F;&#x7A7A;&#x683C;&#xFF09;&#xFF0C;&#x53CC;&#x5F15;&#x53F7;&#x5D4C;&#x5957;&#x53CC;&#x5F15;&#x53F7;&#x4E4B;&#x95F4;&#x4E0D;&#x5141;&#x8BB8;&#x51FA;&#x73B0;&#x7A7A;&#x4E32;&#xFF1A;</p>
<pre class="language-"><code class="lang-dart"><span class="token comment">//String str5 = &apos;&#x5355;&#x5F15;&#x53F7;&apos;&apos;&apos;&apos;&#x5355;&#x5F15;&#x53F7;&apos;;  //&#x62A5;&#x9519;&#x4E86;&#xFF0C;&#x9017;&#x6BD4;</span>
String str6 <span class="token operator">=</span> <span class="token string">&apos;&#x5355;&#x5F15;&#x53F7;&apos;</span><span class="token string">&apos; &apos;</span><span class="token string">&apos;&#x5355;&#x5F15;&#x53F7;&apos;</span><span class="token punctuation">;</span>
String str7 <span class="token operator">=</span> <span class="token string">&apos;&#x5355;&#x5F15;&#x53F7;&apos;</span><span class="token string">&apos;*&apos;</span><span class="token string">&apos;&#x5355;&#x5F15;&#x53F7;&apos;</span><span class="token punctuation">;</span>
String str8 <span class="token operator">=</span> <span class="token string">&quot;&#x53CC;&#x5F15;&#x53F7;&quot;</span><span class="token string">&quot; &quot;</span><span class="token string">&quot;&#x53CC;&#x5F15;&#x53F7;&quot;</span><span class="token punctuation">;</span>
String str9 <span class="token operator">=</span> <span class="token string">&quot;&#x53CC;&#x5F15;&#x53F7;&quot;</span><span class="token string">&quot;*&quot;</span><span class="token string">&quot;&#x53CC;&#x5F15;&#x53F7;&quot;</span><span class="token punctuation">;</span>
<span class="token comment">//String str10 = &quot;&#x53CC;&#x5F15;&#x53F7;&quot;&quot;&quot;&quot;&#x53CC;&#x5F15;&#x53F7;&quot;;   //&#x62A5;&#x9519;&#x4E86;&#xFF0C;&#x9017;&#x6BD4;</span>
<span class="token function">print</span><span class="token punctuation">(</span><span class="token string">&quot;yc-str6--&quot;</span> <span class="token operator">+</span> str6<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token function">print</span><span class="token punctuation">(</span><span class="token string">&quot;yc-str7--&quot;</span> <span class="token operator">+</span> str7<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token function">print</span><span class="token punctuation">(</span><span class="token string">&quot;yc-str8--&quot;</span> <span class="token operator">+</span> str8<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token function">print</span><span class="token punctuation">(</span><span class="token string">&quot;yc-str9--&quot;</span> <span class="token operator">+</span> str9<span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre>
<footer class="page-footer"><span class="copyright">Copyright &#xA9; YoungGary 2019 all right reserved&#xFF0C;powered by Gitbook</span><span class="footer-modification">&#x8BE5;&#x6587;&#x4EF6;&#x4FEE;&#x8BA2;&#x65F6;&#x95F4;&#xFF1A;
2020-01-03 16:31:06
</span></footer>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="dart1.html" class="navigation navigation-prev " aria-label="Previous page: 1.Dart语言(1)">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="widget1.html" class="navigation navigation-next " aria-label="Next page: 3.Flutter初始化">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"2.Dart语言(2)","level":"1.3.2","depth":2,"next":{"title":"3.Flutter初始化","level":"1.3.3","depth":2,"path":"flutter/widget1.md","ref":"flutter/widget1.md","articles":[]},"previous":{"title":"1.Dart语言(1)","level":"1.3.1","depth":2,"path":"flutter/dart1.md","ref":"flutter/dart1.md","articles":[]},"dir":"ltr"},"config":{"plugins":["theme-comscore","prism","-highlight","copy-code-button","search-pro","-search","-lunr","expandable-chapters","splitter","-sharing","tbfed-pagefooter","anchor-navigation-ex"],"styles":{},"pluginsConfig":{"tbfed-pagefooter":{"copyright":"Copyright &copy YoungGary 2019","modify_label":"该文件修订时间：","modify_format":"YYYY-MM-DD HH:mm:ss"},"prism":{"css":["prismjs/themes/prism-solarizedlight.css"],"lang":{"shell":"bash"}},"splitter":{},"search-pro":{},"fontsettings":{"theme":"white","family":"sans","size":2},"anchor-navigation-ex":{"associatedWithSummary":true,"float":{"floatIcon":"fa fa-navicon","level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false},"mode":"float","multipleH1":true,"pageTop":{"level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false},"printLog":false,"showGoTop":true,"showLevel":false},"theme-comscore":{},"copy-code-button":{},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"expandable-chapters":{}},"theme":"default","author":"Gary","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"Gary的小窝","language":"zh-hans","gitbook":"*","description":"Gary的小窝. 里面包含了个人撰写的技术文章"},"file":{"path":"flutter/dart2.md","mtime":"2020-01-03T08:31:06.068Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2021-09-09T14:10:10.930Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-copy-code-button/toggle.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search-pro/jquery.mark.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search-pro/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-splitter/splitter.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-theme-comscore/test.js"></script>
        
    

    </body>
</html>

